package com.action;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.pojo.Achievement;
import com.service.AchievementService;
import com.vo.ResponseBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@CrossOrigin("*")
@RequestMapping("achievement")
public class AchievementAction {

    @Autowired
    private AchievementService achievementService;


    /**
     *  添加考试成绩
     * @param achievement  成绩信息
     * @return
     */
    @RequestMapping("/addAchievement")
    public ResponseBean addAchievement(Achievement achievement){
        // 将学生考试成绩加入成绩表中
        int n=achievementService.addAchievement(achievement);
        return new ResponseBean(0,0,n);
    }

    @RequestMapping("/searchRewind")
    public ResponseBean searchRewind(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit, @RequestParam Map m){
        IPage iPage = achievementService.searchRewind(page,limit,m);
        return new ResponseBean(0,iPage.getTotal(),iPage.getRecords());
    }
}
